// ============================================================================
//
// Copyright (C) 2006-2008 Dengues
//
// Google Group: http://groups.google.com/group/dengues
//
// QQ Group: 24885404
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// ============================================================================
package org.dengues.reports.editor.design.ruler;

import org.dengues.reports.editor.design.models.AbstractReportsElement;

/**
 * Qiang.Zhang.Adolf@gmail.com class global comment. Detailled comment <br/>
 * 
 * $Id: Dengues.epf Qiang.Zhang.Adolf@gmail.com 2008-8-22 qiang.zhang $
 * 
 */
public class RepEditorGuide extends AbstractReportsElement {

    private static final long serialVersionUID = 1546548888888L;

    public static final int LEFT = 0;

    public static final int RIGHT = 1;

    /**
     * Property used to notify listeners when the parts attached to a guide are changed
     */
    public static final String PROPERTY_CHILDREN = "subparts changed"; //$NON-NLS-1$

    private boolean horizontal;

    private int direction;

    private int position;

    /**
     * Getter for position.
     * 
     * @return the position
     */
    public int getPosition() {
        return this.position;
    }

    /**
     * Sets the position.
     * 
     * @param position the position to set
     */
    public void setPosition(int position) {
        this.position = position;
    }

    /**
     * Getter for direction.
     * 
     * @return the direction
     */
    public int getDirection() {
        return this.direction;
    }

    /**
     * Sets the direction.
     * 
     * @param direction the direction to set
     */
    public void setDirection(int direction) {
        this.direction = direction;
    }

    public RepEditorGuide(boolean isHorizontal, int direction) {
        setHorizontal(isHorizontal);
        setDirection(direction);
    }

    /**
     * Getter for horizontal.
     * 
     * @return the horizontal
     */
    public boolean isHorizontal() {
        return this.horizontal;
    }

    /**
     * Sets the horizontal.
     * 
     * @param horizontal the horizontal to set
     */
    public void setHorizontal(boolean horizontal) {
        this.horizontal = horizontal;
    }

    /**
     * Qiang.Zhang.Adolf@gmail.com Comment method "getPropertyName".
     * 
     * @return
     */
    public String getPropertyName() {
        if (getDirection() == LEFT && !isHorizontal()) {
            return IRepRulerEditorConstants.LEFT_MARGIN_PROP;
        } else if (getDirection() == RIGHT && !isHorizontal()) {
            return IRepRulerEditorConstants.RIGHT_MARGIN_PROP;
        } else if (getDirection() == LEFT && isHorizontal()) {
            return IRepRulerEditorConstants.TOP_MARGIN_PROP;
        } else if (getDirection() == RIGHT && isHorizontal()) {
            return IRepRulerEditorConstants.BOTTOM_MARGIN_PROP;
        }
        return null;
    }
}
